<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Mail;
use Session;
class emailController extends Controller
{
    public function email(Request $request)
    {
    	$this -> validate($request,[
              'email'=>'email'
         	],[ 'email.email' => '请输入正确的邮箱格式'
        ]);
        $data = $request -> except('_token');
        $email = $data['email'];
        $rand = rand(1000,9999);
    	Mail::raw('请保管好这个验证码'.$rand, function($message) use ($email){
    		$message -> to($email);
    		$message -> subject('这是邮箱的主题');
    	});
    	Session::put('ed',$rand);
    	Session::put('email',$email);
    	return redirect('/home/index/register');
    }
}
